package com.example.hokoblurdemo.ability.slice;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;
import ohos.app.Context;

import com.example.hokoblurdemo.ability.DynamicBlurAbliity;
import com.example.hokoblurdemo.ability.EasyBlurAbility;
import com.example.hokoblurdemo.ability.JumpUtil;
import com.example.hokoblurdemo.ability.MultiBlurAbility;
import com.example.hokoblurdemo.ability.ResourceTable;


public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener {
    private Context context;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main_new);
        context = getContext();
        initView();
    }

    private void initView(){
        Button multiBlurBtn = (Button)findComponentById(ResourceTable.Id_multi_blur);
        Button dynamicBtn = (Button)findComponentById(ResourceTable.Id_dynamic_blur);
        Button easyBlurBtn = (Button)findComponentById(ResourceTable.Id_easy_blur);

        multiBlurBtn.setClickedListener(this);
        dynamicBtn.setClickedListener(this);
        easyBlurBtn.setClickedListener(this);
    }
    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    public void onClick(Component component) {
        switch (component.getId()){
            case ResourceTable.Id_multi_blur:
                JumpUtil.jumpToAbility(context, MultiBlurAbility.class,(Text) component);
                break;
            case ResourceTable.Id_dynamic_blur:
                JumpUtil.jumpToAbility(context, DynamicBlurAbliity.class,(Text) component);
                break;
            case ResourceTable.Id_easy_blur:
                JumpUtil.jumpToAbility(context, EasyBlurAbility.class,(Text) component);
                break;
            default:
                break;
        }
    }
}
